use figlet_rs::FIGfont;
use std::fs::File;
use std::io::{self, Write};

pub struct BannerTool;

impl BannerTool {
    pub(crate) fn generate_banner(project_name: &str) -> String {
        // Load the standard font
        let standard_font = FIGfont::standard().unwrap();
        let figure = standard_font.convert(project_name).expect("Failed to convert project name to banner");
        figure.to_string()
    }

    pub(crate) fn write_banner_to_file(banner: &str, file_path: &str) -> io::Result<()> {
        let mut file = File::create(file_path)?;
        file.write_all(banner.as_bytes())?;
        Ok(())
    }
}

fn main() {
    let project_name = "xinhou-rocket-admin";
    let banner = BannerTool::generate_banner(project_name);
    match BannerTool::write_banner_to_file(&banner, "banner.txt") {
        Ok(_) => log::info!("Banner generated successfully!"),
        Err(e) => log::error!("Failed to write banner to file: {}", e),
    }
}
